import Vue from 'vue';
import VueRouter from 'vue-router';
import WeatherContent from '../components/WeatherContent.vue';
import About from '../components/About.vue';
import Search from "../components/Search";

Vue.use(VueRouter);

const routes = [
  {
    path: '/',
    name: 'WeatherContent',
    component: WeatherContent,
  },
  {
    path: '/about',
    name: 'About',
    component: About,
  },
  {
    path: '/search',
    name: 'Search',
    component: Search,
  },
];

const originalPush = VueRouter.prototype.push
VueRouter.prototype.replace = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes,
  scrollBehavior(to, from, savedPosition) {
    return { x: 0, y: 0 }
  }
});

export default router;
